<?php
 
class child
{
public function __construct($tb_name)
{
$this->tb_name = $tb_name;
}
private $tb_name;
private $childIds;
private function _getChildIds($pid = '0',$pk_str='id',$pid_str ='pid')
{
$childItem_arr = $GLOBALS['db']->getAll('select id from '.DB_PREFIX.$this->tb_name.' where '.$pid_str.'='.$pid);
if($childItem_arr)
{
foreach($childItem_arr as $childItem)
{
$this->childIds[] = $childItem[$pk_str];
$this->_getChildIds($childItem[$pk_str],$pk_str,$pid_str);
}
}
}
public function getChildIds($pid = '0',$pk_str='id',$pid_str ='pid')
{
$this->childIds = array();
$this->_getChildIds($pid,$pk_str,$pid_str);
return $this->childIds;
}
}

?>